<template>
  <div class="list">
    <div class="article_item" v-for="item in currentNewList" :key="item.art_id">
        <h3 class="van-ellipsis">{{item.title}}</h3>
        <div  v-if="item.cover.type === 1" class="img_box">
            <img :src="img" class="w100" v-for="(img, index) in item.cover.images" :key="index" />
        </div>
        <div v-else-if="item.cover.type === 3" class="img_box">
            <img :src="img" class="w33" v-for="(img, index) in item.cover.images" :key="index" />
        </div>
        <!---->
        <div class="info_box">
        <span>{{item.aut_name}}</span>
        <span>{{item.comm_count}}评论</span>
        <span>{{item.pubdate}}</span>
        </div>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  computed: {
    ...mapGetters(['currentNewList', 'currentCategory'])
  },
  created () {
    this.$store.dispatch('newList/getNewList', this.currentCategory)
  },
  // 监听currentCategory改变
  watch: {
    currentCategory (newCategory) {
      this.$store.dispatch('newList/getNewList', newCategory)
    }
  }
}
</script>

<style>

</style>
